const db=wx.cloud.database()
Component({
  data: {
    

      stu_out: "2021-09-01",
      stu_come:"2021-09-01",
      region: ['广东省', '广州市', '海珠区'],
      dialogShow: false,
      buttons: [{text: '取消'}, {text: '确定'}],
  },
  methods:{
    //添加
btnSub(res){
  wx.showLoading({
    title: '新建请假条中...',
    mask:true
  })
  var {stu_name,stu_id,stu_class,stu_college,teacher_name,stu_out,stu_come,stu_days,region,other}=res.detail.value;
  var cherk=false;
  var pass=false;
  db.collection("leave").add({
    data:{
      cherk,pass,stu_name,stu_id,stu_class,stu_college,teacher_name,stu_out,stu_come,stu_days,region,other
    } 
  }).then(res=>{
    console.log(res)
    wx.hideLoading(
      {
      success: (res) => {
        wx.showToast({
        title: '成功',
        icon:"success",
        duration:2000,
      })
    },
    }
    )
  })
  
 },
      bindMultiPickerChange: function (e) {
        console.log('picker发送选择改变，携带值为', e.detail.value)
        this.setData({
          multiIndex: e.detail.value
        })
      },

      bindDateChange: function (e) {
          this.setData({
            stu_out: e.detail.value,
              [`formData.stu_out`]: e.detail.value
          })
      },
      bindDateChange1: function (e) {
        this.setData({
          stu_come: e.detail.value,
            [`formData.stu_come`]: e.detail.value
        })
    },
      bindRegionChange: function (e) {
        console.log('picker发送选择改变，携带值为', e.detail.value)
        this.setData({
          region: e.detail.value
        })
      },
      openConfirm: function () {
        this.setData({
            dialogShow: true
        })
    },
    tapDialogButton(e) {
        this.setData({
            dialogShow: false
        })
    },
  }
  }
)

// Page({
//   data: {
//       dialogShow: false,
//       buttons: [{text: '取消'}, {text: '确定'}],
//   },
//   openConfirm: function () {
//       this.setData({
//           dialogShow: true
//       })
//   },
//   tapDialogButton(e) {
//       this.setData({
//           dialogShow: false
//       })
//   }
// }
